<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/5/27 0027
 * Time: 9:02
 */

namespace member;

use classes\Node;

abstract class permission
{
    /**
     * 权限验证
     * @return bool
     */
    public function validate(){
        $nodes = $this->list_nodes(); // 取有权限的节点集
        return array_key_exists(Node::code_current(), $nodes); // 若当前访问节点在有权节点集中则有权限咯
    }

    /**
     * 取节点集
     * @return false|\PDOStatement|string|\think\Collection
     */
    public function list_nodes(){
        $dao_node = db('Node');
        $rs_node = $dao_node->select();
        return $rs_node;
    }
}